const Koa = require('koa');
const router = require('koa-router')();
const app = new Koa();


 // 添加路由
 router.get('/', async (ctx, next) => {
    ctx.response.body = `<h1>index page 页面来了 </h1>`
})

router.get('/home', async (ctx, next) => {
    ctx.response.body = '<h1>HOME page 页面来了</h1>'
})

router.get('/404', async (ctx, next) => {
    ctx.response.body = '<h1>404 Not Found找不到</h1>'
})

 // 调用路由中间件
 app.use(router.routes())


let port = 3000;
app.listen(port, () => {
    console.log(' server is running at http://localhost:' + port);
})